package interclass;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Test3
{
    //目标：搞清楚匿名匿名内部类的使用场景
    public static void main(String[] args)
    {
        JFrame win = new JFrame("登录窗口");
        win.setSize(300,200);
        win.setLocationRelativeTo(null);
        win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel panel = new JPanel();
        win.add(panel);
        JButton btn = new JButton("登录");
        panel.add(btn);
        //java要求必须给按钮添加一个监听器对象，这样可以监听用户的点击操作。
        btn.addActionListener(new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                System.out.println("用户点击了登录按钮,登录成功");
            }
        });

        win.setVisible(true);
    }

}
